package com.tutu.entity;

import org.springframework.beans.factory.InitializingBean;

/**
 * @Program: Spring_New
 * @Description:
 * @Author: JK.TuTu
 * @Create: 2022-09-13 21:12
 **/
public class User implements InitializingBean {
    private String name;

    private String password;

    public void setName(String name) {
        this.name = name;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * 无参构造方法
     */
    public User() {
        System.out.println("User的无参构造方法");
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", password='" + password + '\'' +
                '}';
    }

    /**
     * bean实列的init方法
     */
    public void init(){
        System.out.println("User的初始化方法");
    }

    /**
     * bean实例的destory方法
     */
    public void destroy() {
        System.out.println("User的销毁方法");
    }


    /**
     * 实现InitializingBean接口，重写afterPropertiesSet方法，类似于init方法，比init方法执行实际更早
     * @throws Exception
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet方法的执行");

    }
}
